/* DISPLAY TITLE          */
/*GUI preprocessor directive settings */

&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

define variable site like ld_site.
define variable site1 like ld_site.

define variable buyer like rqm_buyer.
define variable buyer1 like rqm_buyer.

define variable rqnbr like rqm_mstr.rqm_nbr.
define variable rqnbr1 like rqm_mstr.rqm_nbr.

define variable part like pt_part.
define variable part1 like pt_part.

define variable vend like ad_addr.
define variable vend1 like ad_addr.

/*GUI preprocessor Frame A define */

&SCOPED-DEFINE PP_FRAME_NAME A
FORM  
    site  COLON 25
    site1 COLON 50 SKIP
    buyer  COLON 25
    buyer1 COLON 50 SKIP
    rqnbr colon 25
    rqnbr1 colon 50 skip
    part  COLON 25
    part1 COLON 50 SKIP
    vend  COLON 25
    vend1 COLON 50 skip
with frame a SIDE-LABELS no-underline width 80 THREE-D .
/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME
/* SET EXTERNAL LABELS */
SetFrameLabels(FRAME a:HANDLE) .

{wbrp01.i}

repeat:

    IF site1 = hi_char THEN site1 = "".
    IF buyer1 = hi_char THEN buyer1 = "".
    IF rqnbr1 = hi_char  THEN rqnbr1 = "".
    IF vend1 = hi_char  THEN vend1 = "".
    IF part1 = hi_char THEN part1 = "".

   if c-application-mode <> 'web' THEN

      update site site1 buyer buyer1 rqnbr rqnbr1 part part1 vend vend1 with frame a editing:

      if frame-field = "site" then do:
         {mfnp.i si_mstr site si_site site si_site si_site}
         if recno <> ? then do:
            site = si_site.
            display site with frame a.
         end.
      end.
      else if frame-field = "site1" then do:
         {mfnp.i si_mstr site1 si_site site1 si_site si_site}
         if recno <> ? then do:
            site1 = si_site.
            display site1 with frame a.
         end.
      end.
      else if frame-field = "buyer" then do:
         {mfnp01.i code_mstr buyer code_value ""pt_buyer"" code_fldname code_fldval}
         if recno <> ? then do:
            buyer = code_value.
            display buyer with frame a.
         end.
      end.
      else if frame-field = "buyer1" then do:
          {mfnp01.i code_mstr buyer1 code_value ""pt_buyer"" code_fldname code_fldval}
          if recno <> ? then do:
             buyer1 = code_value.
             display buyer1 with frame a.
          end.
      end.
      else if frame-field = "part" then do:
         {mfnp.i pt_mstr part pt_part part pt_part pt_part}
         if recno <> ? then do:
            part = pt_part.
            display part with frame a.
         end.
      end.
      else if frame-field = "part1" then do:
         {mfnp.i pt_mstr part1 pt_part part1 pt_part pt_part}
         if recno <> ? then do:
            part1 = pt_part.
            display part1 with frame a.
         end.
      end.
      else if frame-field = "rqnbr" then do:
         {mfnp.i rqm_mstr rqnbr rqm_nbr rqnbr rqm_nbr rqm_nbr}
         if recno <> ? then do:
            rqnbr = rqm_nbr .
            display rqnbr with frame a.
         end.
      end.
      else if frame-field = "rqnbr1" then do:
         {mfnp.i rqm_mstr rqnbr1 rqm_nbr rqnbr1 rqm_nbr rqm_nbr}
         if recno <> ? then do:
            rqnbr1 = rqm_nbr.
            display rqnbr1 with frame a.
         end.
      end.
      else if frame-field = "vend" then do:
         {mfnp.i vd_mstr vend vd_addr vend vd_addr vd_addr}
         if recno <> ? then do:
            vend = vd_addr.
            display vend with frame a.
         end.
      end.
      else if frame-field = "vend1" then do:
         {mfnp.i vd_mstr vend1 vd_addr vend1 vd_addr vd_addr}
         if recno <> ? then do:
            vend1 = vd_addr.
            display vend1 with frame a.
         end.
      end.
      else do:
         status input.
         readkey.
         apply lastkey.
      end.

   end.

   DISP site site1 rqnbr rqnbr1 part part1 vend vend1 WITH FRAME a .

   IF site1 = "" THEN site1 = hi_char.
   IF buyer1 = "" THEN buyer1 = hi_char.
   IF vend1 = "" THEN vend1 = hi_char.
   IF rqnbr1 = "" THEN rqnbr1 = hi_char.
   IF part1 = "" THEN part1 = hi_char.

   {wbrp06.i &command = update &fields = "  site site1 buyer buyer1 rqnbr rqnbr1 part part1 vend vend1" &frm = "a"}

       if (c-application-mode <> 'web') or
          (c-application-mode = 'web' and
          (c-web-request begins 'data'))
       then do:
          hide frame rqd.
       end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "terminal"
               &printWidth = 132
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}
               
   loopa:

   for each rqm_mstr no-lock where rqm_nbr >= rqnbr and rqm_nbr <= rqnbr1 and rqm_buyer >= buyer and rqm_buyer <= buyer1,
       each rqd_det no-lock where rqd_nbr = rqm_nbr and rqd_status = "" and rqd_site >= site and rqd_site <= site1 
       and rqd_part >= part and rqd_part <= part1 and rqd_vend >= vend and rqd_vend <= vend1 
       break by rqd_nbr with frame rqd width 132 stream-io :
     
       {mfguichk.i } /*Replace mfrpchk*/
         
       setframelabels(frame rqd:handle) .

       if page-size - line-counter < 1 THEN
           PAGE .
       
       if first-of(rqd_nbr) then
       do: 
           display
               rqd_nbr
               rqm_buyer .
       end.

       display
           rqd_line rqd_part rqd_um rqd_req_qty rqd_need_date rqd_vend rqd_site .

       if last-of(rqd_nbr) then
           down 1 .

   end.
   {mfreset.i}

   {mfgrptrm.i} /*Report-to-Window*/

   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}

end.

{wbrp04.i &frame-spec = a}

